package com.exsun.ex1077.network.entity

import com.exsun.ex1077.extend.toPhotoUrl
import com.zhangping.fastjetpack.extend.roundDown
import kotlin.math.roundToInt

//{
//    "companyName": "迎泽区",
//    "numberPlate": "晋AW9622",
//    "dvo": "020191104690",
//    "day": "2023-03-28 00:00:00",
//    "mileage": 104500,
//    "oilConsumption": 0.7315,
//    "kilometer": 104.5,
//    "driverMinutes": 154.5,
//    "comapnyShortName": "迎泽区",
//    "companyId": ""
//}

data class MileageRank(
    var rank: Int = 1,
    val comapnyShortName: String = "",
    val companyId: String = "",
    val companyName: String = "",
    val day: String = "",
    val driverMinutes: Double = 0.0,
    val dvo: String = "",
    val kilometer: Double = 0.0,
    val mileage: Int = 0,
    val numberPlate: String = "",
    val oilConsumption: Double = 0.0,
    val name: String = "",
    val picture: List<Photo>? = null
){
    fun kmFormat1() = kilometer.roundDown(1)

    fun kmFormat3() = kilometer.roundDown(3)

    fun personFormat() = "负责人：${name}"

    fun driverMinutesFormat() = "行驶时长：${driverMinutes.roundDown(1)}分钟"

    fun photoFormat() = if (picture.isNullOrEmpty()) null else picture[0].path.toPhotoUrl()
}